import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [
  {
	path:"*",//访问任何没有的页面，默认去 首页
	redirect:"/home"
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
	meta:{
		isShow:true
	}
  },
  {
    path: '/classify',
    name: 'Classify',
    component: () => import('../views/Classify.vue'),
	meta:{
		isShow:true
	}
  },
  {
    path: '/cart',
    name: 'Cart',
    component: () => import('../views/Cart.vue'),
	meta:{//设置一个变量isShow， true 展示底部栏，false不展示底部栏
		isShow:true
	}
  },
  {
    path: '/my',
    name: 'My',
    component: () => import('../views/My.vue'),
	meta:{
		isShow:true
	}
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('../views/Login.vue'),
	meta:{
		isShow:false
	}
  },
  {
    path: '/info/:aid',
    name: 'Info',
    component: () => import('../views/Info.vue'),
  	meta:{
  		isShow:false
  	}
  }
]

//路由重复跳转，报错提示，取消
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

const router = new VueRouter({
  routes
})

export default router
